package chixing.day10.homework;


public class Reverse {

    public static void main(String[] args) {
        String str = "hello";
        str=fun(str);
        System.out.println(str);
    }
    /**
     * 实现字符串反转功能
     */
    public static String fun(String str){
        //转换成byte数组，反着存起来
        byte[] bytes = str.getBytes();
        byte[] bytes1 = new byte[str.length()];
        int i=0;
        for (int j = bytes.length - 1; j >= 0; j--) {
            bytes1[i++] = bytes[j];
        }
        String s = new String(bytes1);
        return s;
    }
}
